﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Roslyn.Compilers.CSharp;
using PathSplitterUtil;

namespace PathSplitter
{
    public abstract class BranchNamer<T>
    {
        private int lastBranchId = 0;

        public abstract T GetBranchNameForId(int id);
        public abstract int GetIdForBranchName(T branchName);

        public T GetNextBranchName()
        {
            return GetBranchNameForId(lastBranchId++);
        }
    }
    public class BranchNamerForList<T> : BranchNamer<T>
    {
        private readonly IList<T> branchNames;
        public BranchNamerForList(IList<T> branchNames)
        {
            this.branchNames = branchNames;
        }

        public override T GetBranchNameForId(int id)
        {
            return branchNames[id];
        }

        public override int GetIdForBranchName(T branchName)
        {
            return branchNames.IndexOf(branchName);
        }
    }
    public class IntBranchNamer : BranchNamer<int>
    {
        public IntBranchNamer()
        { }

        public override int GetBranchNameForId(int id)
        {
            return id;
        }

        public override int GetIdForBranchName(int branchName)
        {
            return branchName;
        }
    }
}
